package com.pxmeta.admin.config;

import cn.authing.core.auth.AuthenticationClient;
import cn.authing.core.mgmt.ManagementClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AuthingConfig {

    @Value("${authing.userPoolId}")
    private String userPoolId;
    @Value("${authing.userPoolSecret}")
    private String userPoolSecret;
    @Value("${authing.appId}")
    private String appId;
    @Value("${authing.appSecret}")
    private String appSecret;
    @Value("${authing.appHost}")
    private String appHost;

    @Bean
    public ManagementClient managementClient(){
        return new ManagementClient(this.userPoolId,this.userPoolSecret);
    }

    @Bean
    public AuthenticationClient authenticationClient(){
        AuthenticationClient authenticationClient = new AuthenticationClient(this.appId, this.appHost);
        authenticationClient.setSecret(appSecret);
        return authenticationClient;
    }
}
